
import 'package:flutter/cupertino.dart';
import 'package:umeng_common_sdk/umeng_common_sdk.dart';
import 'package:umeng_push_sdk/umeng_push_sdk.dart';
import 'dart:io';

void registerPush() {
  UmengPushSdk.setLogEnable(true);
  UmengPushSdk.setPushEnable(true);
  if (Platform.isIOS) {
    UmengCommonSdk.initCommon(
        "",
        "66d71292cac2a664dea17abc",
        "AppStore",
        "fdfd929828f48895ad31792e63940c37");

    UmengPushSdk.register("66d71292cac2a664dea17abc", "AppStore");
    print("IOS");
  } else if (Platform.isAndroid) {
    print("安卓");
    UmengCommonSdk.initCommon(
        "66d71292cac2a664dea17abc",
        "",
        "dev",
        "fdfd929828f48895ad31792e63940c37");

    UmengPushSdk.register("66d71292cac2a664dea17abc", "dev");
  }
}

//注册
register() async{
   () => registerPush();
}
//获取DeviceToken
getDeviceToken () async {
  String? deviceToken = await UmengPushSdk.getRegisteredId();
  if (deviceToken != null) {
    debugPrint("$deviceToken\n");
  }
}

//添加别名
addAlias () async {
  String? alias = "${await UmengPushSdk.addAlias("myAlias", "SINA_WEIBO").toString()}\n";
  if (alias != null) {
    debugPrint("$alias\n");
  }
}

//添加别名
removeAlias () async {
  String? alias = "${await UmengPushSdk.removeAlias("myAlias", "SINA_WEIBO").toString()}\n";
  if (alias != null) {
    debugPrint("$alias\n");
  }
}

//绑定别名
setAlias () async {
  String? alias = "${await UmengPushSdk.setAlias("myAlias", "SINA_WEIBO").toString()}\n";
  if (alias != null) {
    debugPrint("$alias\n");
  }
}

//添加标签
addTags () async {
  String? alias = "${await UmengPushSdk.addTags(["myTag1", "myTag2", "myTag3"]).toString()}\n";
  if (alias != null) {
    debugPrint("$alias\n");
  }
}

//添加标签
removeTags () async {
  String? alias = "${await UmengPushSdk.removeTags(["myTag1", "myTag2", "myTag3"]).toString()}\n";
  if (alias != null) {
    debugPrint("$alias\n");
  }
}

//获取已设置的标签
getAllTags () async {
  String? alias = "${await UmengPushSdk.getTags().toString()}\n";
  if (alias != null) {
    debugPrint("$alias\n");
  }
}

//打开推送功能
openPush () async {
  String? alias = "${UmengPushSdk.setPushEnable(true)}\n";
  if (alias != null) {
    debugPrint("$alias\n");
  }
}

//关闭推送功能
closePush () async {
  String? alias = "${UmengPushSdk.setPushEnable(false)}\n";
  if (alias != null) {
    debugPrint("$alias\n");
  }
}

